package com.wuyoucar.controller;

import com.wuyoucar.common.ResultBean;
import com.wuyoucar.entity.TUser;
import com.wuyoucar.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/consumer")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/loginByName")
    public ResultBean getUser(TUser tUser){
        return userService.getUser(tUser);
    }

    //使用手机号进行登录
    @RequestMapping("/loginByCode")
    public ResultBean loginByCode(String usertel,String code){
        System.out.println(usertel);
        return userService.loginByCode(usertel,code);
    }

    //获取手机注册验证码
    @RequestMapping("/getCode/{usertel}")
    public ResultBean getCode(@PathVariable("usertel") String usertel){
        return userService.getCode(usertel);
    }

    //获取手机登录验证码
    @RequestMapping("/loginCode/{usertel}")
    public ResultBean loginCode(@PathVariable("usertel")String usertel){
        return userService.loginCode(usertel);
    }
}
